<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>计时终端信息查询</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/validata.js"></script>
<script type="text/javascript" src="../../js/http.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
</head>
<body>
	<form id="form1">
	<table class="table table-bordered .table-condensed">
		<tr>
			<td>ID:</td>
			<td id="id"></td>
			<td>编号:</td>
			<td id="devnum"></td>
		</tr>
		<tr>
			<td>培训机构:</td>
			<td id="school"></td>
			<td>终端类型:</td>
			<td>
				<select name="termtype" style="width: 140px;">
					<option value="1">车载计程计时终端</option>
					<option value="2">课堂教学计时终端</option>
					<option value="3">模拟训练计时终端</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>手机号:</td>
			<td>						 
				<input type="text" name="mobile" class="required phone"/>
				<input type="hidden" name="id" />
			</td>
			<td>生产厂家:</td>
			<td>
				<input type="text" name="vender" class="required maxlength:50"/>
			</td>
		</tr>
		<tr>
			<td>终端型号:</td>
			<td>
				<input type="text" name="model" class="required maxlength:150"/>
			</td>
			<td>IMEI:</td>
			<td>
				<input type="text" name="imei" class="required conlength:15" maxlength="15"/>
			</td>
		</tr>
		<tr>
			<td>MAC:</td>
			<td>
				<input type="text" name="mac" class="required maxlength:50"/>
			</td>
			<td>SN:</td>
			<td>
				<input type="text" name="sn" class="required maxlength:50"/>
			</td>
		</tr>
		<tr>
			<td>固件版本号:</td>
			<td>
				<input type="text" name="fedition" class="required maxlength:50"/>
			</td>
			<td>软件版本号:</td>
			<td>
				<input type="text" name="sedition" class="required maxlength:50"/>
			</td>
		</tr>
		<tr>
			<td>SIM卡号:</td>
			<td>
				<input type="text" name="sim" class="required maxlength:50"/>
			</td>
			<td>SIM卡类型:</td>
			<td id="simType"></td>
		</tr>
		<tr>
			<td>绑定教练车:</td>
			<td id="car"></td>
			<td>安装日期:</td>
			<td id="installDate"></td>
		</tr>
		<tr>
			<td>流程:</td>
			<td id="flow"></td>
			<td>流程描述:</td>
			<td id="flowRemark"></td>
		</tr>
		<tr>
			<td>终端证书口令:</td>
			<td id="passwd"></td>
			<td>是否注册:</td>
			<td id="isRegister"></td>
		</tr>
		<tr>
			<td colspan="5" style="text-align: center;" id="btnTd">
				<button type="button" onclick="updateStu();" class="btn btn-info">修改</button>
			</td>
		</tr>
	</table>
	</form>
    <script type="text/javascript">
    	var href = location.href.split("=");
    	var cheZaiId = href[1];
    	getCheZai(cheZaiId);
    	
    	//获取终端资料
    	function getCheZai(id){
    		$.ajax({
    			url : "../../cheZai/get.ao",
    			type : 'POST',
    			data : {
    				"id" : id
    			},
    			beforeSend : ajaxstar,
    			complete : ajaxend,
    			cache : false,
    			dataType : "json",
    			success : function(data) {
    				if (data["state"] == "success") {
    					if(data["result"]["flowBa"] == 99){//添加备案按钮
							var funPath = "..\\\\..\\\\http_device\\\\reviewDevicePutOnRecord.ao"; //备案绑定的教练车
    						var delBaBtn = '<button type="button" onclick="baAn(\''+funPath+'\','+id+');" class="btn btn-danger">备案绑定教练车</button>';
							funPath = "..\\\\..\\\\http_device\\\\deleteDevicePutOnRecord.ao"; //删除备案
    						delBaBtn += '&nbsp;<button type="button" onclick="baAn(\''+funPath+'\','+id+');" class="btn btn-danger">删除备案</button>';
    						$("#btnTd").append(delBaBtn);
    					}else if(data["result"]["flowBa"] == 100){
    						var funPath = "..\\\\..\\\\http_device\\\\devRemBindDevicePutOnRecord.ao"; //解除教练车的备案
    						var delBaBtn = '&nbsp;<button type="button" onclick="baAn(\''+funPath+'\','+id+');" class="btn btn-danger">解除教练车备案</button>';
    						$("#btnTd").append(delBaBtn);
    					}
    					$("table").find("td").each(function(){//不更改的字段
    						var id = $(this).attr("id");
    						if(id != null && typeof(id) != "undefined"){
    							if(id == "simg"){
    								$(this).html("<img style='width:102px;heigth:126px;' src='"+pickerProjectAdd+data["result"][id]+"' />");
    							}else{
    								$(this).html(data["result"][id]);
    							}
    						}
    					});
    					$("table").find("input").each(function(){//文本框内容
    						var name = $(this).attr("name");
    						if(name != null && typeof(name) != "undefined"){
    							$(this).val(data["result"][name]);
    						}
    					});
    					$("table").find("select").each(function(){//下拉列表框
    						var name = $(this).attr("name");
    						if(name != null && typeof(name) != "undefined"){
    							$(this).val(data["result"][name]);
    						}
    					});
    				} else {
    					sAlert(data["result"]);
    				}
    			}
    		});
    	}
    	
    	//修改终端信息
    	function updateStu(){
    		if(validata("form1")){
        		$.ajax({
        			url : "../../cheZai/update.ao",
        			type : 'POST',
        			data :$("#form1").serialize(),
        			cache : false,
        			beforeSend : ajaxstar,
        			complete : ajaxend,
        			dataType : "json",
        			success : function(data) {
    					sAlert(data["result"]);
        				if(data["state"] == "success"){
        					location.reload();
        				}
        			}
        		});
    		}
    	}
    </script>
</body>
</html>